/*
 * This file is part of Herschel Common Science System (HCSS).
 * Copyright 2001-2011 Herschel Science Ground Segment Consortium
 *
 * HCSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * HCSS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with HCSS.
 * If not, see <http://www.gnu.org/licenses/>.
 */

package ml2;
import org.astrogrid.samp.Message;
import org.astrogrid.samp.Metadata;
import org.astrogrid.samp.client.ClientProfile;
import org.astrogrid.samp.client.DefaultClientProfile;
import org.astrogrid.samp.client.HubConnector;
import org.astrogrid.samp.client.SampException;

public class JsampTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
	
	ClientProfile profile = DefaultClientProfile.getProfile();

	HubConnector hubConnector= new HubConnector(profile);
	Metadata meta = new org.astrogrid.samp.Metadata();
	meta.setName("MuLens");
	meta.setDescriptionText("Microlensing tool");
	hubConnector.declareMetadata(meta);
	// This step required even if no custom message handlers added.
	hubConnector.declareSubscriptions(hubConnector.computeSubscriptions());

	// Keep a look out for hubs if initial one shuts down
	hubConnector.setAutoconnect(10);
	Message message = new Message("ds9.set");
	message.addParam("cmd", " file /home/pgomez/workspace/mulens/magPattern1.fits");
	try {
	    System.out.println("SAMP command: " + message.toString() );
	    hubConnector.getConnection().notifyAll(message);
	} catch (SampException e) {
	    e.printStackTrace();
	}


    }
	
	

}
